﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using forum.ApplicationCode;

namespace forum
{
    public partial class AdminArea : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // Reload the page, not from broswer's cache
            Response.AppendHeader("Cache-Control", "no-store");

            if (!Membership.IsAdmin())
                Response.Redirect("forumWelcome.aspx");

            if (Session["addSubForumName"] != null)
                Response.Redirect("AdminAddForum.aspx");

            if (!IsPostBack)
            {




                ddlSubForumDeletePopUp.DataSource = ListManager.GetSubForumList();
                ddlSubForumDeletePopUp.DataTextField = "_Text";
                ddlSubForumDeletePopUp.DataValueField = "_Value";
                ddlSubForumDeletePopUp.DataBind();
                ddlSubForumDeletePopUp.Items.Insert(0, new ListItem("Choose Sub forum", "0"));
                ddlSubForumDeletePopUp.Items[0].Selected = true;


                ddlSubForum.DataSource = ListManager.GetSubForumList();
                ddlSubForum.DataTextField = "_Text";
                ddlSubForum.DataValueField = "_Value";
                ddlSubForum.DataBind();


                ddlSubForumAdd.DataSource = ListManager.GetSubForumList();
                ddlSubForumAdd.DataTextField = "_Text";
                ddlSubForumAdd.DataValueField = "_Value";
                ddlSubForumAdd.DataBind();


                ddlUsers.DataSource = ListManager.GetFirstForumCandidateList();
                ddlUsers.DataTextField = "_Text";
                ddlUsers.DataValueField = "_Value";
                ddlUsers.DataBind();
                ddlUsers.Items.Insert(0, new ListItem("Choose Users", "0"));
                ddlUsers.Items[0].Selected = true;


                ddlModerators.DataSource = ListManager.GetFirstForumModerators();
                ddlModerators.DataTextField = "_Text";
                ddlModerators.DataValueField = "_Value";
                ddlModerators.DataBind();
                ddlModerators.Items.Insert(0, new ListItem("Choose Moderator", "0"));
                ddlModerators.Items[0].Selected = true;

                ddlUsersMessages.DataSource = ListManager.GetUserList();
                ddlUsersMessages.DataTextField = "_Text";
                ddlUsersMessages.DataValueField = "_Value";
                ddlUsersMessages.DataBind();


                ddlNewAdmin.DataSource = ListManager.GetUserList();
                ddlNewAdmin.DataTextField = "_Text";
                ddlNewAdmin.DataValueField = "_Value";
                ddlNewAdmin.DataBind();
          
                /*
                chkbxlstAddSubForumModerators.DataSource = ListManager.GetNewSubForumModerators();
                chkbxlstAddSubForumModerators.DataTextField = "_Text";
                chkbxlstAddSubForumModerators.DataValueField = "_Value";
                chkbxlstAddSubForumModerators.DataBind();
                 */
            }

        }
    }
}